import request from '../../utils/request';
import config from '../../utils/config';

const { api } = config;
const { information: {
  industryList,
  sonIndustryList,
} } = api;

type IndustryListInput = {
	idyId?: string, // 行业id
}
type IndustryListOutput = {
  code: number,
  note: string,
  records: {
		idyId: string,	//行业id
		idyName: string,	//行业名称
		idyLvl: string,	//行业评级
		roneWeekRor: string,	//近一周收益率
		roneMthRor: string,	//近一月收益率
		rthreMthRor: string,	//近三月收益率
		roneYearRor: string,	//近一年收益率
		cyearRor: string,	//今年以来收益率
		newPrc: string,	//最新价
		chgPrc: string,	//价格变化
		ror: string,	//收益率
	}[]
};
// 查询行业列表
export async function IndustryList(payload: IndustryListInput): Promise<IndustryListOutput> {
  const option = {
    url: industryList, // v1.information.industry.list
    method: 'GET',
    data: payload,
  };
  return request(option);
}

type SonIndustryListInput = {
	idyId: string, // 行业id
}
type SonIndustryListOutput = {
  code: number,
  note: string,
  records: {
		idyId: string,	//行业id
		idyName: string,	//行业名称
		roneWeekRor: string,	//近一周收益率
		roneMthRor: string,	//近一月收益率
		rthreMthRor: string,	//近三月收益率
		roneYearRor: string,	//近一年收益率
		cyearRor: string,	//今年以来收益率
		ror: Array<any>,	//收益率
	}[]
};
// 查询下级行业列表
export async function SonIndustryList(payload: SonIndustryListInput): Promise<SonIndustryListOutput> {
  const option = {
    url: sonIndustryList, // v1.information.sonIndustry.list
    method: 'GET',
    data: payload,
  };
  return request(option);
}
